package com.jd.finance.oss.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jd.finance.oss.model.OssObject;
import org.apache.ibatis.annotations.Mapper;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author LiQingBo
 * @since 2022-05-29
 */
@Mapper
public interface OssObjectMapper extends BaseMapper<OssObject> {

    /**
     * 依据objectId查询一个对象
     *
     * @param objectId 对象ID
     * @return OSSObjects 对象实体类
     */
    default OssObject query(Long objectId) {
        OssObject ossObjects = new OssObject();
        ossObjects.setObjectId(objectId);
        return query(ossObjects);
    }

    /**
     * 依据objectKey查询一个对象
     *
     * @param objectKey 对象在阿里云OSS的bucket存储区中对应的key
     * @return OSSObjects 对象实体类
     */
    default OssObject query(String objectKey) {
        OssObject ossObjects = new OssObject();
        ossObjects.setObjectKey(objectKey);
        return query(ossObjects);
    }

    /**
     * 依据条件查询一个对象
     *
     * @param ossObjects 查询参数
     * @return OSSObjects 对象实体类
     */
    OssObject query(OssObject ossObjects);

    /**
     * 依据ID删除一条记录
     *
     * @param objectId 对象ID
     * @return int 1-成功，0-失败
     */
    int delete(Long objectId);
}
